#include <iostream>
#include <vector>

using namespace std;

class Solution
{
public:
    int firstMissingPositive(vector<int> &nums)
    {
        for (int &num : nums)
        {
            if (num <= 0)
                num = INT_MAX;
        }
        for (int i = 0; i < nums.size(); i++)
        {
            if (nums[i] == 0)
                continue;
            int index = abs(nums[i]);
            if (index > nums.size())
                continue;
            index--;
            nums[index] = -abs(nums[index]);
        }
        for (int i = 0; i < nums.size(); i++)
        {
            if (nums[i] >= 0)
                return i + 1;
        }
        return nums.size() + 1;
    }
};

int main()
{
    cout << "Code41" << endl;
    Solution s;
    vector<int> nums = {0, 1, 2};
    cout << s.firstMissingPositive(nums) << endl;
    return 0;
}